-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Remove unnecesary "as" casts. #32701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
(rust_highfive has picked a reviewer for you, use r? to override) |
src/libstd/sys/windows/c.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HANDLE is a *mut c_void and you can't apply ! to a pointer.
ee1582a to
7280e4b
Compare
|
Passes "make check" on Linux and on Mingw. |
src/libarena/lib.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this was changed? Seems slightly less readable now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the original code did the correct thing (but it did/does). !0 on its own is an i32 (value -1). i32 cast to a pointer is valid, yet this seems to infer using usize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bluss It appears that !0 as *mut T has a magical power to fix the type of the integer literal to usize. It looks more and more suspicious when we see that LLVM inttoptr is defined as zero extention.
- "0 as *mut _" -> "ptr::null_mut()"; and the same goes for ptr::null() - Simplify "0 as c_int" to "0" when the context already expects c_int - And so on... Signed-off-by: NODA, Kai <[email protected]>
7280e4b to
ecfacb5
Compare
|
☔ The latest upstream changes (presumably #32980) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Closing due to inactivity, but feel free to resubmit with a rebase! |
0 as *mut _->ptr::null_mut(); and the same goes forptr::null()0 as c_intto0when the context already expectsc_int